package com.tianyu.jty.shop.service;

import com.tianyu.jty.common.service.IBaseDao;
import com.tianyu.jty.common.service.IBaseNativeQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tianyu.jty.common.persistence.HibernateDao;
import com.tianyu.jty.common.service.BaseService;
import com.tianyu.jty.shop.dao.GoodsTypeDao;
import com.tianyu.jty.shop.entity.GoodsType;

import java.util.List;

/**
 * 商品类型service
 * @author ty
 * @date 2015年1月22日
 */
@Service
@Transactional(readOnly=true)
public class GoodsTypeService extends BaseService<GoodsType, Integer> {
	
	@Autowired
	private GoodsTypeDao goodsTypeDao;

	@Autowired
	private IBaseNativeQuery baseNativeQuery;

	@Autowired
	private IBaseDao baseDao;

	@Override
	public HibernateDao<GoodsType, Integer> getEntityDao() {
		return goodsTypeDao;
	}

	public List findAll(){
		return this.goodsTypeDao.createSQLQuery("select * from goods_type", new Object[]{ }).list();
	}

    @Transactional(readOnly = false)
	public int executeNativeSql(){
		String sql = "INSERT INTO reserve_person VALUES (?, ?, ?, ?, ?, ?, ?)";
		return baseDao.executeNativeSql(sql, new Object[]{1, 1, "2017-11-21 09:16:25", null, null, "备注一", 0});
	}
}
